<?php
/**
 * Celebrio Database module
 * 
 * @copyright  Copyright (c) 2011 Celebrio Software
 * @package    Celebrio
 * @subpackage Database
 */
namespace Celebrio\Database;

use Nette\Object;

use \dibi;

use Celebrio\Database\IDatabase;

/**
 * Azure
 *
 * @author     Albireo Solutions
 * @package    Kernel
 */
class MSSQL extends Object implements IDatabase {

    public function __construct() {
        //$this->database = new DatabaseModule();
    }

    public function console($query) {
        //return $this->database->console($query);
    }

    
    public function createLogin ( $username, $pass, $newUser = true) {
        $init = new MSSQLInit();
        $init->createLogin($username, $pass, $newUser);
    }

    public function deleteLogin ( $username ) {
        $init = new MSSQLInit();
        $init->deleteLogin($username);
    }

    /* --------------- DataBase Functions (DBF) ------------------------ */
    
    public function dbfConcat($first, $second) {
        return $first . " + " . $second;
    }

    public function dbfSubstr($string, $from, $for = null) {
        if ($for === null) {
            return "substring(" . $string . ", " . $from . ", " . $this->dbfStrlen($string) . ")";
        } else {
            return "substring(" . $string . ", " . $from . ", " . $for . ")";
        }
    }

    public function dbfStrlen($string) {
        return "len(" . $string . ")";
    }


}
